<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            background: #f00;
        }
    </style>
  </head>
  <body>
    <div id="app">
    <!-- .self代表事件只能由自身触发 -->
      <div class="box" @click.self="fn3">
        <a @click="fn" href="http://www.baidu.com">点我跳转</a>
        <!-- vue里有更好的方式实现事件对象的一些功能 -->
        <a @click.prevent.stop="fn2" href="http://www.baidu.com">点我跳转</a>

        <!-- 给事件只绑定一次 -->
        <button @click.once="fn2">我是按钮</button>
      </div>
    </div>

    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        methods: {
          fn (e) {
            alert('123')
            e.preventDefault()
          },
          fn2 () {
            alert(123)
          },
          fn3 () {
            alert('父盒子')
          }
        }
      })
    </script>
  </body>
</html>
